package cn.edu.pet.servlet.admin;

import cn.edu.pet.entity.AdoptRecord;
import cn.edu.pet.entity.Pets;
import cn.edu.pet.repo.AdoptRecordRepo;
import cn.edu.pet.repo.PetRepo;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/admin/adopt/update")
public class AdoptRecordUpdateServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        String id = req.getParameter("id");
        String status = req.getParameter("status");
        AdoptRecord adoptRecord = new AdoptRecord();
        adoptRecord.setId(Integer.valueOf(id));
        adoptRecord.setStatus(Integer.valueOf(status));
        AdoptRecordRepo.getInstance().updateAdoptRecord(adoptRecord);
        resp.sendRedirect("/admin/adopt_index.html");
    }
}
